import matplotlib.pyplot as plt
from matplotlib import rcParams
import platform

# 根据操作系统设置中文字体
def setup_chinese_fonts():
    """设置支持中文的字体"""
    system = platform.system()
    
    if system == "Darwin":  # macOS
        font_list = ['Arial Unicode MS', 'PingFang SC', 'Hiragino Sans GB', 'STHeiti', 'SimHei']
    elif system == "Windows":  # Windows
        font_list = ['SimHei', 'Microsoft YaHei', 'KaiTi', 'FangSong', 'Arial Unicode MS']
    else:  # Linux
        font_list = ['WenQuanYi Zen Hei', 'WenQuanYi Micro Hei', 'SimHei', 'DejaVu Sans']
    
    rcParams['font.sans-serif'] = font_list
    rcParams['axes.unicode_minus'] = False  # 解决负号显示问题

# 初始化字体设置
setup_chinese_fonts()
